package top.lshaci.learning.alibaba.cloud.seata.storage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import top.lshaci.learning.alibaba.cloud.seata.storage.entity.Storage;

/**
 * StorageMapper
 *
 * @author lshaci
 * @since 1.0.0
 */
public interface StorageMapper extends BaseMapper<Storage> {

    /**
     * 扣除存储数量
     *
     * @param commodityCode 商品编号
     * @param count         数量
     */
    @Update("update storage_tbl set count = count - #{count} where commodity_code = #{commodityCode}")
    void deduct(@Param("commodityCode") String commodityCode, @Param("count") int count);
}
